package com.muqi.app.user.widget;

import com.muqi.app.qlearn.student.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class RecordTextEntry extends RelativeLayout {
	private View parentView;
	private ImageView mIcon;
	private TextView mTitle;
	private TextView mContent;
	private boolean isShow;
	private boolean isEdit;
	
	public RecordTextEntry(Context context, String title, String content) {
		super(context);
		init(context,null);
		mTitle.setText(title);
		mContent.setText(content);
	}

	public RecordTextEntry(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context,attrs);
	}

	public RecordTextEntry(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		init(context,attrs);
	}

	private void init(Context context,AttributeSet attrs) {
		LayoutInflater inflater = LayoutInflater.from(context);
		parentView = inflater.inflate(R.layout.record_text_entry, this);
		mTitle = (TextView) parentView.findViewById(R.id.title);
		mContent = (TextView) parentView.findViewById(R.id.recordText);
		 // 通过上下文context获取自定义属性  
        TypedArray typeArr = context.obtainStyledAttributes(attrs,R.styleable.MineEntryText);  
        // 获取在xml文件中,自定义属性的值  
        if(typeArr!=null){
        	 isEdit = typeArr.getBoolean(R.styleable.MineEntryText_mine_isEditable,false); 
             isShow = typeArr.getBoolean(R.styleable.MineEntryText_mine_isShowNext,true);
             //释放资源  
             typeArr.recycle(); 
        }
        
       
	}
	
	public void setTitle(String title){
		mTitle.setText(title);
	}
	
	public void setContent(String content){
		mContent.setText(content);
	}
	
	public void setBackground(int resId) {
		parentView.setBackgroundResource(resId);
	}
	
	public void setContentSize(float size) {
		mContent.setTextSize(size);
	}

	public void setContentColor(int resId) {
		mContent.setTextColor(resId);
	}
	
	/**
	 * 
	 */
	public String getContentValue() {
		return mContent.getText().toString().trim();
	}
	
	/**
	 *  
	 * @return 返回对应的key
	 */
	public String getTitleValue(){
		return mTitle.getText().toString().trim();
	}
}
